<?php
require_once("xmlparser.php");

class XMLHopsParser extends XMLParser {
    protected function getResult() {
    	$src = htmlspecialchars($this->array["distance_n"]["_"]["source"]);
        $hps = htmlspecialchars($this->array["distance_n"]["_"]["hops"]);

	if ( isset($this->array["distance_n"]["person"]) ) {
	    sort($this->array["distance_n"]["person"]);
	    $num = count($this->array["distance_n"]["person"]);
            $result = "<p>There are <strong>$num persons</strong> at a distance of <strong>$hps hops</strong> from <strong>$src</strong> (using your filters):</p>";
	    $result .="<ul>";
	    if ( !is_array( $this->array["distance_n"]["person"] ) )
	        $result.="<li>".$this->array["distance_n"]["person"]."</li>";
	    else foreach ( $this->array["distance_n"]["person"] as &$pers )
                $result.="<li>$pers</li>";
	    $result .="</ul>";
        } else {
            $result = "<p>There is no people at a distance of <strong>$hps hops</strong> from <strong>$src</strong> using your filters!</p>";
        }
        return $result;
    }
}
?>
